<?php
require_once( dirname( __FILE__ ) . '/inc/config.inc.php' );
IsModelPriv('goodsorder');
require_once "function.php";
$id = htmlspecialchars( $id );

$sql = "SELECT f.*,t.dataname as typename,u.nickname as nickname ,u.headimgurl as headimgurl,u.school as school,u.truename as truename,u.sheng as sheng,u.shi as shi,u.qu as qu,u.address as address,u.mobile as mobile FROM `#@__order` as f
		left join `#@__user`  as u on u.id=f.uid
		left join `#@__cascadedata`  as t on t.datavalue=f.apply_type  
		WHERE t.datagroup='type'  AND   f.delstate='' AND f.id=$id ";


	$row = $dosql->GetOne( $sql );

	$odernum = date( "Ymd", $row[ 'post_time' ] ) . "-" . $row[ 'id' ];
    $gps1=$row['latitude'].",".$row['longitude']; 
	$gps2=$row['latitude2'].",".$row['longitude2']; 
	$has_map='error';
	if(!empty($row['latitude']) && !empty($row['latitude2'])   ){
		$has_map='access';
		
	}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>位置详情</title>
	<link href="templates/style/admin.css" rel="stylesheet" type="text/css"/>
	<script type="text/javascript" src="templates/js/jquery.min.js"></script>
	<script type="text/javascript" src="layer/layer.js"></script>
	<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
	<link rel="stylesheet" href="ui/css/bootstrap.min.css">
	<link rel="stylesheet" href="ui/css/bootstrap-theme.min.css">
	<link rel="stylesheet" href="templates/js/zoomify.min.css">


</head>
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&libraries=geometry"></script>
<script>
function init(){
    var map = new qq.maps.Map(document.getElementById("container"),{
        center:  new qq.maps.LatLng(<?php echo $gps1?>),
        zoom: 14
    });
    var start = new qq.maps.LatLng(<?php echo $gps1?>), end = new qq.maps.LatLng(<?php echo $gps2?>);
    var path1=[
        start,
        end
    ];
    var polyline = new qq.maps.Polyline({
        path: path1,
        strokeColor: '#f90a37',
        strokeWeight: 5,
        editable:false,
        map: map
    });

    document.getElementById("res").innerHTML = Math.round(qq.maps.geometry.spherical.computeDistanceBetween(start, end)*10)/10000;
}
</script>
<body  <?php if($has_map='access'){ echo  'onload="init()"'; }?> style="width:890px;">
	<div class="order_top">
		<div class="order_top1">单号：
			<?php echo $odernum;?>
		</div>
		<div class="order_top1 t_fr">报修日期：
			<?php echo date("Y年m月d日",$row['post_time']);?>
		</div>
	</div>
	<table width="200" border="1" class="table table-bordered">
		<tr>
			<td>单位：</td>
			<td>
				<?php echo $row['school'];?>
			</td>
			<td>联系人：</td>
			<td>
				<?php echo $row['truename']."    ".$row['mobile'];?> </td>
		</tr>
		<tr>

			<td>报修位置信息：</td>
			<td>
				<?php echo $row['latitude'].",".$row['longitude']?>
			</td>
						<td>地址：</td>
			<td>
				<?php echo $row['sheng'].$row['shi'].$row['qu']."-".$row['address']?>
			</td>
		</tr>
		<tr>
			<td>完修位置信息：</td>
			<td>
				<?php echo $row['latitude2'].",".$row['longitude2']?>
			</td>
			<td>两点间直线距离：</td>
			<td>
				<span id="res"></span>公里
			</td>

		</tr>
	
	</table>
<!--  qq map-->
<style type="text/css">
*{
    margin:0px;
    padding:0px;
}

#container {
   min-width:603px;
   min-height:500px;
}
	#res{  color: #F30F13;  font-weight: bolder;}
</style>

<div>
<div id="container"></div>

</body>

</html>